package com.chen.q1.business;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class Student implements BeanNameAware, ApplicationContextAware {
    private int id;
    private String name;

    private String beanNane;
    private ApplicationContext applicationContext;

    public Student(int i, String chen01) {
    }

    public void init(){
        System.out.println("hello,My name is "+ name);
    }

    public static Student create(){
        return new Student(101,"chen01");
    }

    @Override
    public void setBeanName(String s) {
        this.beanNane = s;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    public void print(){
        System.out.println(this.beanNane);
        System.out.println("  context.getBeanDefinitionNames :" + applicationContext.getBeanDefinitionNames());
    }
}
